package com.wjh.feign.impl;

import com.wjh.base.ResponseApiData;
import com.wjh.goods.entity.GoodsEntity;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import com.wjh.feign.IGoodsFeignClient;

import lombok.extern.slf4j.Slf4j;

/**
 * 商品服务容错/熔断处理
 * 
 * @author wenjianhai
 * @date 2023/6/26
 * @since JDK 17
 */
@Slf4j
@Component
public class GoodsFeignClientImpl implements FallbackFactory<IGoodsFeignClient> {
	@Override
	public IGoodsFeignClient create(Throwable cause) {
		return new IGoodsFeignClient() {
			@Override
			public ResponseApiData<GoodsEntity> queryByGuid(String goodsGuid) {
				log.error("查询商品详情-失败.商品Guid:{}, 失败信息:{}", goodsGuid, cause.getMessage());
				return ResponseApiData.systemFail("查询商品详情失败");
			}
		};
	}
}
